﻿using System;
using System.Windows.Forms;

namespace AMM.Forms.Produce {
    public partial class FrmProduce : FrmRootBase {

        private DateTime _currentDatetime;

        public FrmProduce() {
            InitializeComponent();
        }

        private void SetCurrentButtonText() {
            this.btnCurrent.Text = string.Format("{0}-{1}", this._currentDatetime.Year, this._currentDatetime.Month);
        }

        private void btn_click(object sender, EventArgs e) {
            Button btn = (Button)sender;
            switch (btn.Name) {
                case "btnPreYear":
                    this._currentDatetime = this._currentDatetime.AddYears(-1);
                    break;
                case "btnPreMonth":
                    this._currentDatetime = this._currentDatetime.AddMonths(-1);
                    break;
                case "btnNxtMonth":
                    this._currentDatetime = this._currentDatetime.AddMonths(1);
                    break;
                case "btnNxtYear":
                    this._currentDatetime = this._currentDatetime.AddYears(1);
                    break;
                case "btnCurrent":
                    this._currentDatetime = DateTime.Now;
                    break;
            }
            this.cdcProduce.Date = this._currentDatetime;
            this.SetCurrentButtonText();
        }

        private void FrmProduce_Load(object sender, EventArgs e) {
            this.WindowState = FormWindowState.Maximized;
            this._currentDatetime = DateTime.Now;
            this.btn_click(this.btnCurrent, EventArgs.Empty);
        }
    }
}
